$().ready(function() {
	list_module();
	list_module_mobile();
	getFBdetails();
	get_userCount();
	get_hash();
});
$(function() {

    var $sidebar   = $(".left-wrapper-dashboard"), 
        $window    = $(window),
        offset     = $sidebar.offset(),
        topPadding = 0;

    $window.scroll(function() {
        if ($window.scrollTop() > offset.top) {
            $sidebar.stop().animate({
                marginTop: $window.scrollTop() - offset.top + topPadding
            });
        } else {
            $sidebar.stop().animate({
                marginTop: 0
            });
        }
    });
    
});
function getFBdetails(){
	xfunc = "https://graph.facebook.com/522443937801779";
	data_sent = {};
	
	$.ajax({
		type: "GET",
		url: xfunc,
		data: data_sent,
		dataType: 'json',
		success: function(result){
			$("#FBlikes").html(result.likes);
			$("#FBtalks").html(result.talking_about_count);
			$("#FBname").html(result.name);
		}
	});
}
function get_userCount(){
	xfunc = "user_info/get_user_count";
	data_sent = {};
	
	$.ajax({
		type: "GET",
		url: base_url+xfunc,
		data: data_sent,
		dataType: 'json',
		success: function(result){
			$("#userCount").html(result);
		}
	});
}
function list_module(){
	var ksort = 0;
	var asort = 0;
	login_icons = {};
	panel_icons = {};
	xfunc = "module/get_list_module";
	
	data_sent = {};
		
		$.ajax({ 
			type: "POST", // request type POST
			url: base_url+xfunc, // post to PHP file
			data: data_sent, // request send to PHP file
			dataType:'json',
			success: function(result){ // result = return from php request
				$(result.strName).each(function(k,v){
					asort = result.intOrderPanel[k];
					if(result.intBackend[k]==1){
						html_icons_panel = '';
						html_icons_panel +='<li class="btn left-menu well" id="'+result.strBackendLink[k]+'">';
							html_icons_panel +='<a href="javascript:togglenav(\''+result.strBackendLink[k]+'\')">';
								html_icons_panel +='<span class="img-menu-left"><img height="32" class="img-rounded" width="32" src="'+base_url+'assets/img/'+result.strImgLink[k]+'"></span>';
								html_icons_panel += '<span class="menu-name">'+result.strName[k]+'</span>';
							html_icons_panel +='</a>';
						html_icons_panel +='<span class="loader-'+result.strBackendLink[k]+' loader-img" style="display:none"></span><div class="clearfix"></div></li>';
						panel_icons[result.intOrderPanel[k]]=html_icons_panel;
					}
				});
				
				html_panel = '<ul>';
				for(x=0;x<=asort;x++){
					if($.trim(panel_icons[x])!=""){
						html_panel +=panel_icons[x];
					}
								
				}				
				html_panel += '</ul>';
				
				$('#icons-panel').html(html_panel);
			}
		});	
}
function list_module_mobile(){
	var ksort = 0;
	var asort = 0;
	login_icons = {};
	panel_icons = {};
	xfunc = "module/get_list_module";
	
	data_sent = {};
		
		$.ajax({ 
			type: "POST", // request type POST
			url: base_url+xfunc, // post to PHP file
			data: data_sent, // request send to PHP file
			dataType:'json',
			success: function(result){ // result = return from php request
				$(result.strName).each(function(k,v){
					asort = result.intOrderPanel[k];
					if(result.intBackend[k]==1){
						html_icons_panel = '';
						html_icons_panel +='<li id="'+result.strBackendLink[k]+'">';
							html_icons_panel +='<a href="javascript:togglenav(\''+result.strBackendLink[k]+'\')">';
								html_icons_panel += '<span class="menu-name">'+result.strName[k]+'</span>';
							html_icons_panel +='</a>';
						html_icons_panel +='</li>';
						panel_icons[result.intOrderPanel[k]]=html_icons_panel;
					}
				});
				
				html_panel = '';
				for(x=0;x<=asort;x++){
					if($.trim(panel_icons[x])!=""){
						html_panel +=panel_icons[x];
					}
								
				}				
				html_panel += '';
				
				$('#mobile_nav').html(html_panel);
			}
		});	
}